<template>
  <div id="kgecharts">
    <div id="main" style="width: 300px; height: 220px"></div>
  </div>
</template>
<script>
export default {
  name: "kgecharts",
  methods: {
    drawChart() {
      // 基于准备好的dom，初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById("main"));
      // 指定图表的配置项和数据
      let option = {
        title: {
          text: "知识图谱实体类型",
          subtext: "",
          x: "left",
        },

        tooltip: {
          trigger: "item",
        },
        legend: {
          top: "0%", //该模块距离上面模块的距离
          left: "center",
          orient: "vertical",
          left: "60%", //图例距离左的距离
          y: "center", //图例上下居中
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            radius: ["28%", "50%"], // 图的大小:数组元素分别表示内圆大小和外圆大小
            center: ["30%", "40%"], //图的位置，距离左跟上的位置
            avoidLabelOverlap: false,
            itemStyle: {
              borderRadius: 10,
              borderColor: "#fff",
              borderWidth: 1,
            },
            label: {
              show: false,
              position: "center",
            },
            emphasis: {
              label: {
                show: true,
                fontSize: "10", // 内圈字体大小
                fontWeight: "bold",
              },
            },
            labelLine: {
              show: false,
            },
            data: [
              { value: 8808, name: "Disease" },
              { value: 3353, name: "Check" },
              { value: 5998, name: "Symptom" },
              { value: 17201, name: "Producer" },
              { value: 3828, name: "Drug" },
              { value: 4870, name: "Food" },
              { value: 54, name: "Department" },
            ],
          },
        ],
      };
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    },
  },
  mounted() {
    this.drawChart();
  },
};
</script>
